import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:new_yuqib_app/yqbConfig/color_theme.dart';
import 'package:new_yuqib_app/yqbConfig/storage_config.dart';
import 'package:new_yuqib_app/yqbView/WebView/view.dart';

///协议提示阅读内容
class XieYiContentView extends StatelessWidget {
  const XieYiContentView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('个人信息保护指引'),
        titleTextStyle: const TextStyle(fontSize: 18, color: ColorTheme.primaryTextColor),
        centerTitle: true,
        surfaceTintColor: Colors.white,
        leading: const SizedBox(),
      ),
      backgroundColor: Colors.white,
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 12),
          child: RichText(
            text: TextSpan(
              text: "感谢您信任并使用!",
              style: const TextStyle(color: ColorTheme.primaryTextColor),
              children: [
                const TextSpan(text: "\n我们非常重视您的个人信息和隐私保护为了更好地保障您的个人权益。在您使用我们的产品前,请务必审慎阅读"),
                TextSpan(
                    text: "《注册协议》",
                    style: const TextStyle(color: ColorTheme.buttonTextColor),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        Get.to(const WebView(typeId: 0));
                      }),
                const TextSpan(text: "与"),
                TextSpan(
                    text: "《隐私政策》",
                    style: const TextStyle(color: ColorTheme.buttonTextColor),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        Get.to(const WebView(typeId: 1));
                      }),
                const TextSpan(
                    text: "内的所有条款，了解我们申请相关权限及收集使用您信息的情况，以及对个人信息的保护措施。"
                        "\n关于隐私政策保护，特向您说明如下:"
                        "\n1.为向您提供服务并保护您的信息安全，基于您的明示授权，我们需在必要范围内收集、使用、共享并保存您的个人信息。"
                        "\n2.我们会采用业界安全措施标准保护您的信息安全，未经您的授权同意，我们不会向任何第三方共享您的信息或用于您未授权的其他用途。"
                        "\n3.为保障APP稳定运行或提供服务，您可能需要根据不同业务场景开启必要的权限。若您未开启相应权限，则APP不会收集相应的信息。")
              ],
            ),
          ),
        ),
      ),
      bottomNavigationBar: Container(
        color: Colors.white,
        padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            RichText(
              text: TextSpan(
                text: "我已知晓",
                style: const TextStyle(color: ColorTheme.primaryTextColor),
                children: [
                  TextSpan(
                      text: "【隐私政策】",
                      style: const TextStyle(color: ColorTheme.buttonTextColor),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          Get.to(const WebView(typeId: 1));
                        }),
                  const TextSpan(
                    text: "—",
                  ),
                  TextSpan(
                      text: "【注册协议】",
                      style: const TextStyle(color: ColorTheme.buttonTextColor),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          Get.to(const WebView(typeId: 0));
                        }),
                ],
              ),
            ),
            const SizedBox(height: 12),
            Row(
              children: [
                Expanded(
                  child: ElevatedButton(
                      style: ElevatedButton.styleFrom(
                        backgroundColor: ColorTheme.buttonTextColor,
                        padding: const EdgeInsets.symmetric(horizontal: 0),
                        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
                      ),
                      onPressed: () {
                        StorageConfig.xieYi = true;
                        Get.back(result: true);
                      },
                      child: const Text(
                        "同意协议",
                        style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
                      )),
                ),
                const SizedBox(width: 18),
                Expanded(
                  child: ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      backgroundColor: Colors.grey.shade200,
                      padding: const EdgeInsets.symmetric(horizontal: 0),
                      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
                    ),
                    onPressed: () {
                      Get.bottomSheet(
                        const XieYiContentView2(),
                        isDismissible: false,
                      );
                    },
                    child: const Text(
                      "不同意",
                      style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
                    ),
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}

///协议提示阅读内容
class XieYiContentView2 extends StatelessWidget {
  const XieYiContentView2({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('温馨提示'),
        titleTextStyle: const TextStyle(fontSize: 18, color: ColorTheme.primaryTextColor),
        centerTitle: false,
        surfaceTintColor: Colors.white,
        leadingWidth: 0,
        leading: const SizedBox(),
      ),
      backgroundColor: Colors.white,
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 12),
          child: RichText(
            text: TextSpan(
              text: "如果您不同意",
              style: const TextStyle(color: ColorTheme.primaryTextColor),
              children: [
                TextSpan(
                    text: "《注册协议》",
                    style: const TextStyle(color: ColorTheme.buttonTextColor),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        Get.to(const WebView(typeId: 0));
                      }),
                const TextSpan(text: "与"),
                TextSpan(
                    text: "《隐私政策》",
                    style: const TextStyle(color: ColorTheme.buttonTextColor, textBaseline: TextBaseline.alphabetic),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        Get.to(const WebView(typeId: 1));
                      }),
                const TextSpan(text: "我们不会收集可能直接识别您的个人信息,您仍可使用基本模式,以实现基础功能。")
              ],
            ),
          ),
        ),
      ),
      bottomNavigationBar: Container(
          color: Colors.white,
          padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
          child: Row(
            children: [
              Expanded(
                child: ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      backgroundColor: ColorTheme.buttonTextColor,
                      padding: const EdgeInsets.symmetric(horizontal: 0),
                      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
                    ),
                    onPressed: () {
                      Get.back(result: true);
                    },
                    child: const Text(
                      "同意，进入全功能模式",
                      style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
                    )),
              ),
              const SizedBox(width: 18),
              Expanded(
                child: ElevatedButton(
                  style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.grey.shade200,
                    padding: const EdgeInsets.symmetric(horizontal: 0),
                    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
                  ),
                  onPressed: Get.back,
                  child: const Text(
                    "不同意，进入基本模式",
                    style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
                  ),
                ),
              ),
            ],
          )),
    );
  }
}
